package cn.netjava.personblogaction;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cn.netjava.actioninterface.Action;
import cn.netjava.dao.ArticleDao;
import cn.netjava.dao.PhotoAlbumDao;
import cn.netjava.pojo.Article;
import cn.netjava.pojo.PhotoAlbum;

/**
 * this is my person blog home page action
 * @author Administrator
 *
 */
public class PersonIndexAction implements Action{
	
	public String excute(HttpServletRequest request,
			HttpServletResponse response) {

        int uid = Integer.parseInt(request.getParameter("uid"));
		
		/*get the user's article list the put it to the session object*/
		ArticleDao adao =ArticleDao.getArticleDao();
		List<Article> articleList =adao.getAllArticleFromID(uid);
		request.setAttribute("article", articleList);		
		
		/*get the user's photos' list the put it to the session object*/
		PhotoAlbumDao padao =PhotoAlbumDao.getPhotoAlbumDao();
		List<PhotoAlbum> photoAlbumList = padao.getUserPhotoAlbumFromUserID(uid);
		request.setAttribute("userPhotoAlbums", photoAlbumList);
		
		return "JSP/personblogjsp/personindex.jsp";
	}

}
